package com.bigknow.appstore.web.base.entity;

import com.bigknow.appstore.web.framework.entity.BaseEntity;
import com.bigknow.appstore.web.framework.entity.IAuditLog;
import com.bigknow.appstore.web.framework.entity.QueryField;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.mongodb.morphia.annotations.Entity;

import javax.xml.bind.annotation.XmlRootElement;
import java.util.Date;


@XmlRootElement //默认Entity bean都能解析为xml 必须加入这个注解
@Entity("web.base.auditLog")
public class AuditLog extends BaseEntity implements IAuditLog {

    private static final long serialVersionUID = 1L;

    /**
     * 操作人姓名
     */
    @Excel(name = "操作人姓名", width = 20)
    @QueryField
    private String operatorAccount;
    @Excel(name = "操作人地址", width = 20)
    @QueryField
    private String operatorHost;
    @Excel(name = "操作内容", width = 20)
    @QueryField
    private String operationContent;
    @Excel(name = "操作实体ID", width = 20)
    @QueryField
    private String operationEntityId;
    @Excel(name = "操作实体名称", width = 20)
    @QueryField
    private String operationEntityName;
    /**
     * 操作类
     */
    @Excel(name = "操作类", width = 60)
    private String operationClass;

    public enum OperationType {
        INSERT("新增"), UPDATE("更新"), SAVE("保存"), DELETE("删除"), LOGIN("登录"), BUSINESS("业务"), APPLY("申请"),APPLY_DELAY("申请延期"), APPROVE("审批"), REVOKE("撤销"), OTHER("其他"),PUBLISH("发布"),RETIRE("下架");
        private String displayName;

        OperationType(String displayName) {
            this.displayName = displayName;
        }

        public static OperationType get(String type) {
            if ("insert".equalsIgnoreCase(type)) return INSERT;
            if ("update".equalsIgnoreCase(type)) return UPDATE;
            if ("save".equalsIgnoreCase(type)) return SAVE;
            if ("delete".equalsIgnoreCase(type)) return DELETE;
            if ("login".equalsIgnoreCase(type)) return LOGIN;
            if ("business".equalsIgnoreCase(type)) return BUSINESS;
            if ("apply".equalsIgnoreCase(type)) return APPLY;
            if ("apply_delay".equalsIgnoreCase(type)) return APPLY_DELAY;
            if ("approve".equalsIgnoreCase(type)) return APPROVE;
            if ("revoke".equalsIgnoreCase(type)) return REVOKE;
            if ("publish".equalsIgnoreCase(type)) return PUBLISH;
            if ("retire".equalsIgnoreCase(type)) return RETIRE;
            return OTHER;
        }

        public String getDisplayName() {
            return displayName;
        }
    }

    /**
     * 操作类型
     */
    @Excel(name = "操作类型", width = 20)
    @QueryField
    private OperationType operationType;
    /**
     * 操作时间
     */
    @Excel(name = "操作时间", width = 20, format = "yyyy-MM-dd hh:mm:ss")
    private java.util.Date operationTime;

    public OperationType getOperationType() {
        return operationType;
    }

    public void setOperationType(OperationType operationType) {
        this.operationType = operationType;
    }

    public String getOperatorAccount() {
        return operatorAccount;
    }

    public void setOperatorAccount(String operatorAccount) {
        this.operatorAccount = operatorAccount;
    }

    public Date getOperationTime() {
        return operationTime;
    }

    public void setOperationTime(Date operationTime) {
        this.operationTime = operationTime;
    }

    public String getOperationClass() {
        return operationClass;
    }

    public void setOperationClass(String operationClass) {
        this.operationClass = operationClass;
    }

    public String getOperatorHost() {
        return operatorHost;
    }

    public void setOperatorHost(String operatorHost) {
        this.operatorHost = operatorHost;
    }

    public String getOperationEntityName() {
        return operationEntityName;
    }

    public void setOperationEntityName(String operationEntityName) {
        this.operationEntityName = operationEntityName;
    }

    public String getOperationContent() {
        return operationContent;
    }

    public void setOperationContent(String operationContent) {
        this.operationContent = operationContent;
    }

    public String getOperationEntityId() {
        return operationEntityId;
    }

    public void setOperationEntityId(String operationEntityId) {
        this.operationEntityId = operationEntityId;
    }
}

	
